env_name=BoxMOT

cpu_name=$(lscpu | grep "Model name" | awk -F ':' '{print $2}' | sed 's/^[ \t]*//')
echo "CPU name: ${cpu_name}"
is_intel=$(echo ${cpu_name} | grep "Intel")
if [ -z ${is_intel} ]; then
	echo "Not Intel CPU!"
else
	echo "Intel CPU!"
fi

conda_bin_path=$(which conda)
conda_path=$(dirname $(dirname ${conda_bin_path}))
set_var_sh_path="${conda_path}/etc/profile.d/conda.sh"

echo "Try to source ${set_var_sh_path}"

source ${set_var_sh_path}

# Check the env is exist if not set var to true
need_install=False
conda env list | grep ${env_name} || need_install=True

if [ ${need_install} = True ]; then
    echo "Create env ${env_name}"
    conda create -n ${env_name} python=3.11 -y
    conda activate ${env_name}
    
	if [ -z ${is_intel} ]; then
		conda install pytorch torchvision pytorch-cuda=12.4 -c pytorch -c nvidia -y
		conda install numpy -y
	fi
	
	pip install -r requirements.txt

	pip install boxmot
else
	conda activate ${env_name}
fi

python_path=$(which python)
echo "Python path: ${python_path}"

export https_proxy=http://proxy.329509.xyz:7890

export LD_PRELOAD=/opt/lib/fakeintel/libfakeintel.so
export MKL_SERVICE_FORCE_INTEL=1
export MKL_THREADING_LAYER=GNU

export NVI_NOTIFY_IGNORE_TASK=1

python SORT_Infer.py
